<%-- 
    Document   : editUser
    Created on : Sep 8, 2011, 10:56:23 AM
    Author     : HIEP
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<script>
    function validUser(){
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        var name = document.forms["Users"]["fullname"].value;
        var address = document.forms["Users"]["address"].value;
        var phone = document.forms["Users"]["phone"].value;
        var nationality = document.forms["Users"]["nationality"].value;
        var email = document.forms["Users"]["email"].value;
        var password = document.forms["Users"]["password"].value;
        
        if(name == "" || name == null){
            alert("Please enter fullname!");
            return false;
        }
        if(address == "" || address == null){
            alert("Please enter address!");
            return false;
        }
        if(phone == "" || phone == null){
            alert("Please enter phone!");
            return false;
        }
        if(nationality == "" || nationality == null){
            alert("Please enter nationality!");
            return false;
        }
        if(email == "" || email == null){
            alert("Please enter email!");
            return false;
        }
        if(reg.test(email) == false) {
            alert('Invalid email address!');
            return false;
        }
        if(password == "" || password == null){
            alert("Please enter password!");
            return false;
        }
        return true;
    }
</script>

<!DOCTYPE html>
<div id="content" class="roundedBorders">
    <!-- Title -->
    <div id="title" class="b2">
        <h2>Edit Profile</h2>
    </div>
    <!-- Title -->
    <!-- Inner Content -->
    <div id="innerContent">
        <logic:notEmpty name="item">
            <!-- Form -->
            <html:form onsubmit="return validUser();" action="/UserAction.do?method=update" method="POST">
                <div class="fieldset fieldsetBlock active tabs">
                    <div class="header">
                        <h3>Edit Profile</h3>
                    </div>
                    <div class="tabs">
                        <fieldset id="fieldset1" >
                            <legend>Post content</legend>
                            <html:hidden name="item" property="id"/>
                            <div class="field required">
                                <label>Full name</label> 
                                <html:text styleClass="text" property="fullname" name="item"/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div class="field required">
                                <label>Address</label> 
                                <html:text styleClass="text" property="address" name="item"/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div class="field required">
                                <label>Phone</label> 
                                <html:text styleClass="text" property="phone" name="item"/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div class="field required">
                                <label>Nationality</label> 
                                <html:text styleClass="text" property="nationality" name="item"/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div class="field required">
                                <label>Email</label> 
                                <html:text styleClass="text" property="email" name="item"/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div class="field required">
                                <label>Password</label> 
                                <html:password styleClass="text" property="password" name="item" value=""/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <html:hidden property="role" name="item"/>
                            <div id="buttom1">
                                <strong>
                                    <html:submit value="Update" styleClass="buttom_form"/>
                                </strong>
                                <strong>    
                                    <html:cancel value="Cancel" styleClass="buttom_form"/>
                                </strong>
                            </div>
                        </fieldset>
                    </div>
                    <span class="bBR"></span>
                </div>
            </html:form>
            <!-- /Form -->
        </logic:notEmpty>
    </div>
    <!-- /Inner Content -->
    <div class="bBottom"><div></div></div>
</div>
